<%
System.out.println("======== Report by module =========");
//--------------------------------------------------------------------------------->
//
// Copyright 2002 e Professional Corporation.  All Rights Reserved.
//
// File:       	CFHDRPRP05.jsp
//
// Author:   	Udong
//
// Start Date:	XX/01/48
//
// Finish Date: XX/XX/XXXX 
//
// Update Date : xx/xx/xxxx by Who
// ............????????..........
//--------------------------------------------------------------------------------->
%>
<HTML>
<HEAD>
<STYLE>
.titleNormal{
	font-family: Cordia ;
	font-size:11px;
	font-weight:normal;
}
</STYLE>
<%@ page 
		language			="java"
		contentType	="text/html; charset=CP874"
		pageEncoding="CP874"
		import				="java.util.Vector,java.util.Date,
										com.softplus.carrefour.hd.CFHDSystem,
										com.softplus.carrefour.hd.bltier.report.ICaseReportViewer,
										com.softplus.carrefour.hd.bltier.report.CCaseReportManage,
										com.softplus.carrefour.hd.bltier.entity.CfhdCaseHead,
										java.util.GregorianCalendar,
										java.text.SimpleDateFormat,
										com.softplus.carrefour.hd.bltier.util.DateUtil,
										com.softplus.carrefour.hd.bltier.entity.UserAccount,
										com.softplus.carrefour.hd.bltier.admin.ICountryViewer,
										com.softplus.carrefour.hd.bltier.admin.CountryManage,
										com.softplus.carrefour.hd.bltier.admin.ICFHDSystemViewer,
										com.softplus.carrefour.hd.bltier.admin.CFHDSystemManage,
										com.softplus.carrefour.hd.bltier.entity.CfhdSystem,
										com.softplus.carrefour.hd.bltier.entity.Country"
%>
<%//		
%>

<%@taglib uri="../WEB-INF/HeadTag.tld" prefix="head"%>
<head:Head
		title				="Report List of Cases by System and Module"
		styleFile	="../theme/defaultTheme.css,../theme/CFRLTheme.css,../theme/CFHDReportTheme.css"></head:Head>
</HEAD>
<%
// === define variable ===
		String	selectWidth		= "155";
		String	tableWidth			= "750";
		String[]	columnWidth		= {"170","200","110","70","80","70"};

		String	countryID				= request.getParameter("country")==null? "":request.getParameter("country");
		System.out.println("..............................country id ..."+countryID);
		String	countryName		= "";
		String	caseType			= "";//"P1";
		String	caseTypeALL	= "";
		String	caseType1			= request.getParameter("caseP1")==null? "":request.getParameter("caseP1");//"P1";//
		String	caseType2			= request.getParameter("caseP2")==null? "":request.getParameter("caseP2");//"P2";//
		String	caseType3			= request.getParameter("caseP3")==null? "":request.getParameter("caseP3");//"P3";//
		String	caseType4			= request.getParameter("caseP4")==null? "":request.getParameter("caseP4");//"P4";//

		if ( !caseType1.equals("") && !caseType2.equals("") && !caseType3.equals("")&& !caseType4.equals(""))
		{		caseTypeALL	=	"ALL";		}
	
		String	system					= request.getParameter("system")==null? "":request.getParameter("system");
		String	module					= request.getParameter("module")==null? "":request.getParameter("module");
		String	fromDateStr		= request.getParameter("fromDate")==null?"":request.getParameter("fromDate");
		String	toDateStr				= request.getParameter("toDate")==null?"":request.getParameter("toDate");
		//GregorianCalendar	cal	= new GregorianCalendar();
		//cal.clear();
        //cal.set(2004,0,1);
		Date		fromDate				= new SimpleDateFormat("dd/MM/yyyy").parse(fromDateStr);//cal.getTime();//        Date d1 = cal.getTime(); 
        //cal.set(2005,0,30);
		Date		toDate					= new SimpleDateFormat("dd/MM/yyyy").parse(toDateStr);//cal.getTime();//        Date d2 = cal.getTime(); 

		String	systemAtHeader	= system;
		String	countryNow			= "";
		String	countryPre				= "";
		int			start							= 0;
		int			count							= 0;
		int			vectorSizeGrand	= 0;
		int			countCountry			= 0;
		int			countSystem			= 0;
		int			vectorSize				= 0;
		int			sizeSystem1			=	0;
		int			sizeCountry1			=	0;
		int			sizeCountry2			=	0;
// === define object ===
		ICaseReportViewer		reportManage		=	(CCaseReportManage)CFHDSystem.getControlClass("CASE_REPORT");
		ICountryViewer				countryManage		=	(CountryManage)CFHDSystem.getControlClass("COUNTRY");
		ICFHDSystemViewer	systemManage		=	(CFHDSystemManage)CFHDSystem.getControlClass("SYSTEM");

		// set name of country to show in report.
		if  (!(countryID.equals("ALL")))
		{		countryName	=	countryManage.getCountry(countryID).getCountryName();		}
		else
		{		countryName	=	"ALL";		}

		UserAccount					userSession		=  (UserAccount) request.getSession().getAttribute("userVO");//"kunlaporn_c";
		String								userID					= userSession.getUserId();//"admin";//userVO.getUserId();
// === define vector ===
		Vector	reportVector		=	new Vector(0);
		Vector	systemVector	=	new Vector(0);
		Vector	systemVector1	=	new Vector(0);
		Vector	countryVector	=	new Vector(0);
		Vector	countryVector1	=	new Vector(0);
		Vector	countryVector2	=	new Vector(0);
%>
<BODY style="overflow: auto;">

<script src="../script/spToolbar.js" type="text/javascript"></script>
<a href="CFHDRPMT05.jsp">
		<img alt="Back to criteria page" src="../images/icon/toolbar/nBackToMenu.gif" width="21" height="21" border="0" 
						onmouseout="imgOut(this)" onmouseover="imgOver(this)" /></a>

<DIV align="center" id="masterZone" style="height:170px; overflow-x: hidden; overflow-y: hidden;">
<TABLE width="<%=tableWidth%>" cellspacing="0" cellpadding="0" border="0" bordercolor="red">
	<TR>
			<TD>
					<SPAN class="Header">E-Helpdesk</SPAN>
					<SPAN class="Header">List of Cases by System and Module</SPAN>
					<SPAN class="viewCaseHeader"  style="text-align: right;">Create Date: 
																	<%=new SimpleDateFormat("dd/MM/yyyy HH:mm").format(DateUtil.getLocalDate(userID))%></SPAN>
					<SPAN class="viewCaseHeader">System: <%=system%></SPAN>
					<SPAN class="viewCaseHeader">Module: <%=module%></SPAN>
					<SPAN class="viewCaseHeader">Country: <%=countryName%></SPAN>
					<SPAN class="viewCaseHeader">Case Type: 
					<%if (caseType1.equals("P1")){%><%=CfhdCaseHead.getCaseTypeDesc(caseType1)%>(<%=CfhdCaseHead.CASE_USER_QUESTION%>)<%}%>
					<%if (caseType2.equals("P2")){%><%=CfhdCaseHead.getCaseTypeDesc(caseType2)%>(<%=CfhdCaseHead.CASE_PROBLEM_REPORT%>)<%}%>
					<%if (caseType3.equals("P3")){%><%=CfhdCaseHead.getCaseTypeDesc(caseType3)%>(<%=CfhdCaseHead.CASE_CHANGE_REQUEST%>)<%}%>
					<%if (caseType4.equals("P4")){%><%=CfhdCaseHead.getCaseTypeDesc(caseType4)%>(<%=CfhdCaseHead.CASE_SERVICE_REQUEST%>)<%}%>
					</SPAN>
					<SPAN class="viewCaseHeader">Open Case Date From: 
															<%=new SimpleDateFormat("dd/MM/yyyy").format(fromDate)%>
															To: <%=new SimpleDateFormat("dd/MM/yyyy").format(toDate)%></SPAN>
			</TD>
	</TR>
	<TR>
			<TD>
					<TABLE width="<%=tableWidth%>" cellspacing="0" cellpadding="0" border="0" bordercolor="blue" bgcolor="darkorange">
						<TR>
							<TD class="titleFont" style="text-align: center; color: white;" width="<%=columnWidth[0]%>">Case ID</TD>
							<TD class="titleFont" style="text-align: left; color: white;" width="<%=columnWidth[1]%>">Subject</TD>
							<TD class="titleFont" style="text-align: center; color: white;" width="<%=columnWidth[2]%>">Open Case Date</TD>
							<TD class="titleFont" style="text-align: center; color: white;" width="<%=columnWidth[3]%>">Status</TD>
							<TD class="titleFont" style="text-align: center; color: white;" width="<%=columnWidth[4]%>">Module</TD>
							<TD class="titleFont" style="text-align: center; color: white;" width="<%=columnWidth[5]%>">Case Type</TD>
						</TR>
					</TABLE>
			</TD>
	</TR>
</TABLE>
</DIV>

<DIV align="center" id="dataZone" style=" overflow-x: hidden;overflow-y: hidden;">
<TABLE width="<%=tableWidth%>" cellspacing="0" cellpadding="0" border="0" bordercolor="yellow">
<%






String	system1	=	"";
String	country1	=	"";

if (system.equals("ALL"))
{
 		System.out.println("................system is all");
		systemVector1	=	systemManage.getListSystem();
		sizeSystem1		=	systemVector1.size();
		 for (int s=0; s<=sizeSystem1; s++)
		 {
		 		if(s == sizeSystem1)
		 		{		system1	=	null;		}
		 		else
		 		{		system1	=	(String)systemVector1.elementAt(s);
				 		System.out.println("...................system..."+system1);		}

							countSystem		= 0;	// reset count of system.
%>
	<TR>
			<TD><TABLE cellspacing="0"><TR><TD><span class="viewCaseHeader">System: <%=system1==null? "Undefined":system1%></span></TD></TR></TABLE></TD>
	</TR>
<%
				if (countryID.equals("ALL"))
				{
						System.out.println(".....................country is all");
						countryVector1	= countryManage.getAllCountry();
						sizeCountry1		=	countryVector1.size();
				 		for (int c=0; c<sizeCountry1; c++)
				 		{
								Country		countryEntity1	=	(Country)countryVector1.elementAt(c);
				 				country1	=	countryEntity1.getCountryId();
				 				System.out.println("........................country..."+country1);
								countCountry		= 0;	// reset count of country.
%>
	<TR>
			<TD class="TotalByCaseTyephaveline"><TABLE width="<%=tableWidth%>"><TR>
										<TD><span class="viewCaseHeader">Country: <%=countryEntity1.getCountryName()%></span></TD></TR></TABLE></TD>
	</TR>


<%
		if (caseTypeALL.equals("ALL"))
		{		start	=	0;
				count	=	0;		}
		else
		{		start	=	1;
				count	=	4;		}
		for (int i=start; i<=count; i++)		// it has 3 case type so it will query 3 times -- except that is all 3 it will query only 1 time.
		{
				String	caseTypeLoop	=	"caseType"+i;
				if (caseTypeLoop.equals("caseType1"))
					{	caseType	=	caseType1;	}
				else if (caseTypeLoop.equals("caseType2"))
					{	caseType	=	caseType2;	}
				else if (caseTypeLoop.equals("caseType3"))
					{	caseType	=	caseType3;	}
				else if (caseTypeLoop.equals("caseType4"))
				{	caseType	=	caseType4;	}
				else if (caseTypeLoop.equals("caseType0"))
					{	caseType	=	caseTypeALL;	}
				// set null for query
				if (caseType.equals(""))
				{		caseType = null;	}
				System.out.println(".........................."+i+"...case..."+caseType+".."+country1+".."+system1+".."+module);//+".."+fromDate+".."+toDate);
				reportVector			=	reportManage.listCaseBySystemAndModule(country1,caseType,system1,module,fromDate,toDate);
				vectorSize				=	reportVector.size();

				vectorSizeGrand	=	vectorSizeGrand+vectorSize;
				System.out.println(".."+vectorSize);

				for(int k=0; k<vectorSize; k++)
				{
						CfhdCaseHead		reportEntity	=	(CfhdCaseHead)reportVector.elementAt(k);
						countryNow	=	reportEntity.getCountry().getCountryName();
						countSystem++;
						countCountry++;
%>
	<TR>
			<TD>
					<TABLE width="<%=tableWidth%>" cellspacing="0" cellpadding="0" border="0" bordercolor="pink">
						<TR>
							<TD class="resultFont" width="<%=columnWidth[0]%>"><%=reportEntity.getCaseId()%></TD>
							<TD class="resultFont" width="<%=columnWidth[1]%>"><%=reportEntity.getSubject()%></TD>
							<TD class="resultFont" width="<%=columnWidth[2]%>" style="text-align: center;">
																								<%="&nbsp;"+new SimpleDateFormat("dd/MM/yy").format(reportEntity.getOpenCaseDate())%></TD>
							<TD class="resultFont" width="<%=columnWidth[3]%>"><%=reportEntity.getStatusDesc(reportEntity.getCaseStatus())%></TD>
							<TD class="resultFont" width="<%=columnWidth[4]%>">
																								<%=reportEntity.getCfhdModule()==null? "Undefined":reportEntity.getCfhdModule()%></TD>
							<TD class="resultFont" width="<%=columnWidth[5]%>" style="text-align: center;"><%=reportEntity.getCaseType()%></TD>
						</TR>
					</TABLE>
			</TD>
	</TR>
<%

							countryPre			=	reportEntity.getCountry().getCountryName();
				}// end FOR write all data.

		}//end FOR loop of start-count 'Case type'

if (vectorSize == 0){	//countCountry = 0;
%>
	<TR>
			<TD><TABLE width="<%=tableWidth%>" cellspacing="0" cellpadding="0"><TR><TD>&nbsp;</TD></TR></TABLE></TD>
	</TR>
<%}%>
	<TR>
			<TD style="border-top: solid 2px #FF8C00">
					<TABLE cellspacing="0" align="right" border="0" bordercolor="green">
						<TR >
							<TD class="TotalByCaseTyephaveline" width="150">Total by Country</TD>
							<TD class="TotalByCaseTyephaveline" style="text-align: center;"><%=countCountry%></TD>
							<TD class="TotalByCaseTyephaveline">Cases</TD>
						</TR>
					</TABLE>
			</TD>
	</TR>
<%
				 		}// end for c(country) loop







				 }else{
				 		System.out.println("..........................................country is not ALL");




							countCountry		= 0;	// reset count of country.
%>
	<TR>
			<TD class="TotalByCaseTyephaveline"><TABLE width="<%=tableWidth%>"><TR>
										<TD><span class="viewCaseHeader">Country: <%=countryManage.getCountry(countryID).getCountryName()%></span></TD></TR></TABLE></TD>
	</TR>
<%
		if (caseTypeALL.equals("ALL"))
		{		start	=	0;
				count	=	0;		}
		else
		{		start	=	1;
				count	=	4;		}
		for (int i=start; i<=count; i++)		// it has 3 case type so it will query 3 times -- except that is all 3 it will query only 1 time.
		{
				String	caseTypeLoop	=	"caseType"+i;
				if (caseTypeLoop.equals("caseType1"))
					{	caseType	=	caseType1;	}
				else if (caseTypeLoop.equals("caseType2"))
					{	caseType	=	caseType2;	}
				else if (caseTypeLoop.equals("caseType3"))
					{	caseType	=	caseType3;	}
				else if (caseTypeLoop.equals("caseType4"))
				{	caseType	=	caseType4;	}
				else if (caseTypeLoop.equals("caseType0"))
					{	caseType	=	caseTypeALL;	}
				// set null for query
				if (caseType.equals(""))
				{		caseType = null;	}
				reportVector			=	reportManage.listCaseBySystemAndModule(countryID,caseType,system1,module,fromDate,toDate);
				vectorSize				=	reportVector.size();

				vectorSizeGrand	=	vectorSizeGrand+vectorSize;
				System.out.println(".."+reportVector.size());

				for(int k=0; k<vectorSize; k++)
				{
						CfhdCaseHead		reportEntity	=	(CfhdCaseHead)reportVector.elementAt(k);
						countryNow	=	reportEntity.getCountry().getCountryName();
						countSystem++;
						countCountry++;
%>
	<TR>
			<TD>
					<TABLE width="<%=tableWidth%>" cellspacing="0" cellpadding="0" border="0" bordercolor="pink">
						<TR>
							<TD class="resultFont" width="<%=columnWidth[0]%>"><%=reportEntity.getCaseId()%></TD>
							<TD class="resultFont" width="<%=columnWidth[1]%>"><%=reportEntity.getSubject()%></TD>
							<TD class="resultFont" width="<%=columnWidth[2]%>" style="text-align: center;">
																								<%="&nbsp;"+new SimpleDateFormat("dd/MM/yy").format(reportEntity.getOpenCaseDate())%></TD>
							<TD class="resultFont" width="<%=columnWidth[3]%>"><%=reportEntity.getStatusDesc(reportEntity.getCaseStatus())%></TD>
							<TD class="resultFont" width="<%=columnWidth[4]%>">
																								<%=reportEntity.getCfhdModule()==null? "Undefined":reportEntity.getCfhdModule()%></TD>
							<TD class="resultFont" width="<%=columnWidth[5]%>" style="text-align: center;"><%=reportEntity.getCaseType()%></TD>
						</TR>
					</TABLE>
			</TD>
	</TR>
<%
							countryPre			=	reportEntity.getCountry().getCountryName();
				}// end FOR write all data.
		}//end FOR loop of start-count 'Case type'
if (vectorSize == 0){	//countCountry = 0;
%>
	<TR>
			<TD><TABLE width="<%=tableWidth%>" cellspacing="0" cellpadding="0"><TR><TD>&nbsp;</TD></TR></TABLE></TD>
	</TR>
<%}%>
	<TR>
			<TD style="border-top: solid 2px #FF8C00">
					<TABLE cellspacing="0" align="right" border="0" bordercolor="green">
						<TR >
							<TD class="TotalByCaseTyephaveline" width="150">Total by Country</TD>
							<TD class="TotalByCaseTyephaveline" style="text-align: center;"><%=countCountry%></TD>
							<TD class="TotalByCaseTyephaveline">Cases</TD>
						</TR>
					</TABLE>
			</TD>
	</TR>
<%




				 }// end if country is ALL or not
%>
	<TR>
			<TD>
					<TABLE cellspacing="0" align="right" border="0" bordercolor="green">
						<TR >
							<TD class="TotalByCaseTyephavelineDoble" width="150">Total by System </TD>
							<TD class="TotalByCaseTyephavelineDoble" style="text-align: center;"><%=countSystem%></TD>
							<TD class="TotalByCaseTyephavelineDoble">Cases</TD>
						</TR>
					</TABLE>
			</TD>
	</TR>
	<TR style="height: 5px;"><TD style="border-bottom: 3px black solid;"><TABLE><TR><TD></TD></TR></TABLE></TD></TR>
<%		 }// end for s(system) loop









}else{
				 		System.out.println("..........................................system is not ALL");
						countSystem		= 0;	// reset count of system.
%>
	<TR>
			<TD><TABLE cellspacing="0"><TR><TD><span class="viewCaseHeader">System: <%=system==null? "Undefined":system%></span></TD></TR></TABLE></TD>
	</TR>
<%
				String	country2	=	"";
				if (countryID.equals("ALL"))
				{
						System.out.println(".....................country is all");
						countryVector2	= countryManage.getAllCountry();
						sizeCountry2		=	countryVector2.size();
				 		for (int c=0; c<sizeCountry2; c++)
				 		{
								Country		countryEntity2	=	(Country)countryVector2.elementAt(c);
				 				country2	=	countryEntity2.getCountryId();
				 				System.out.println("= = = = ........................country..."+country2);

								countCountry		= 0;	// reset count of country.
%>
	<TR>
			<TD class="TotalByCaseTyephaveline"><TABLE width="<%=tableWidth%>"><TR>
										<TD><span class="viewCaseHeader">Country: <%= countryEntity2.getCountryName()%></span></TD></TR></TABLE></TD>
	</TR>
<%
		if (caseTypeALL.equals("ALL"))
		{		start	=	0;
				count	=	0;		}
		else
		{		start	=	1;
				count	=	4;		}
		for (int i=start; i<=count; i++)		// it has 3 case type so it will query 3 times -- except that is all 3 it will query only 1 time.
		{
				String	caseTypeLoop	=	"caseType"+i;
				if (caseTypeLoop.equals("caseType1"))
					{	caseType	=	caseType1;	}
				else if (caseTypeLoop.equals("caseType2"))
					{	caseType	=	caseType2;	}
				else if (caseTypeLoop.equals("caseType3"))
					{	caseType	=	caseType3;	}
				else if (caseTypeLoop.equals("caseType4"))
				{	caseType	=	caseType4;	}
				else if (caseTypeLoop.equals("caseType0"))
					{	caseType	=	caseTypeALL;	}
				// set null for query
				if (caseType.equals(""))
				{		caseType = null;	}
				System.out.println("==.........................."+i+"...case..."+caseType+".."+countryID+".."+system1+".."+module);//+".."+fromDate+".."+toDate);
				reportVector			=	reportManage.listCaseBySystemAndModule(country2,caseType,system,module,fromDate,toDate);
				vectorSize				=	reportVector.size();

				vectorSizeGrand	=	vectorSizeGrand+vectorSize;

				for(int k=0; k<vectorSize; k++)
				{
						CfhdCaseHead		reportEntity	=	(CfhdCaseHead)reportVector.elementAt(k);
						countryNow	=	reportEntity.getCountry().getCountryName();
						countSystem++;
						countCountry++;
%>
	<TR>
			<TD>
					<TABLE width="<%=tableWidth%>" cellspacing="0" cellpadding="0" border="0" bordercolor="pink">
						<TR>
							<TD class="resultFont" width="<%=columnWidth[0]%>"><%=reportEntity.getCaseId()%></TD>
							<TD class="resultFont" width="<%=columnWidth[1]%>"><%=reportEntity.getSubject()%></TD>
							<TD class="resultFont" width="<%=columnWidth[2]%>" style="text-align: center;">
																								<%="&nbsp;"+new SimpleDateFormat("dd/MM/yy").format(reportEntity.getOpenCaseDate())%></TD>
							<TD class="resultFont" width="<%=columnWidth[3]%>"><%=reportEntity.getStatusDesc(reportEntity.getCaseStatus())%></TD>
							<TD class="resultFont" width="<%=columnWidth[4]%>">
																								<%=reportEntity.getCfhdModule()==null? "Undefined":reportEntity.getCfhdModule()%></TD>
							<TD class="resultFont" width="<%=columnWidth[5]%>" style="text-align: center;"><%=reportEntity.getCaseType()%></TD>
						</TR>
					</TABLE>
			</TD>
	</TR>
<%
							countryPre			=	reportEntity.getCountry().getCountryName();
				}// end FOR write all data.
		}//end FOR loop of start-count 'Case type'
if (vectorSize == 0){	//countCountry = 0;
%>
	<TR>
			<TD><TABLE width="<%=tableWidth%>" cellspacing="0" cellpadding="0"><TR><TD>&nbsp;</TD></TR></TABLE></TD>
	</TR>
<%}%>
<%
%>
	<TR>
			<TD style="border-top: solid 2px #FF8C00">
					<TABLE cellspacing="0" align="right" border="0" bordercolor="green">
						<TR >
							<TD class="TotalByCaseTyephaveline" width="150">Total by Country</TD>
							<TD class="TotalByCaseTyephaveline" style="text-align: center;"><%=countCountry%></TD>
							<TD class="TotalByCaseTyephaveline">Cases</TD>
						</TR>
					</TABLE>
			</TD>
	</TR>
<%					}//end for ALL country







				 }else{
				 		System.out.println("..........................................country is not ALL and system is not ALL");
						countCountry		= 0;	// reset count of country.
%>
	<TR>
			<TD class="TotalByCaseTyephaveline"><TABLE width="<%=tableWidth%>"><TR>
										<TD><span class="viewCaseHeader">Country: <%=countryManage.getCountry(countryID).getCountryName()%></span></TD></TR></TABLE></TD>
	</TR>
<%
		if (caseTypeALL.equals("ALL"))
		{		start	=	0;
				count	=	0;		}
		else
		{		start	=	1;
				count	=	4;		}
		for (int i=start; i<=count; i++)		// it has 3 case type so it will query 3 times -- except that is all 3 it will query only 1 time.
		{
				String	caseTypeLoop	=	"caseType"+i;
				if (caseTypeLoop.equals("caseType1"))
					{	caseType	=	caseType1;	}
				else if (caseTypeLoop.equals("caseType2"))
					{	caseType	=	caseType2;	}
				else if (caseTypeLoop.equals("caseType3"))
					{	caseType	=	caseType3;	}
				else if (caseTypeLoop.equals("caseType4"))
				{	caseType	=	caseType4;	}
				else if (caseTypeLoop.equals("caseType0"))
					{	caseType	=	caseTypeALL;	}
				// set null for query
				if (caseType.equals(""))
				{		caseType = null;	}
				reportVector			=	reportManage.listCaseBySystemAndModule(countryID,caseType,system,module,fromDate,toDate);
				vectorSize				=	reportVector.size();

				vectorSizeGrand	=	vectorSizeGrand+vectorSize;
				System.out.println(".."+reportVector.size());

				for(int k=0; k<vectorSize; k++)
				{
						CfhdCaseHead		reportEntity	=	(CfhdCaseHead)reportVector.elementAt(k);
						countryNow	=	reportEntity.getCountry().getCountryName();
						countSystem++;
						countCountry++;
%>
	<TR>
			<TD>
					<TABLE width="<%=tableWidth%>" cellspacing="0" cellpadding="0" border="0" bordercolor="pink">
						<TR>
							<TD class="resultFont" width="<%=columnWidth[0]%>"><%=reportEntity.getCaseId()%></TD>
							<TD class="resultFont" width="<%=columnWidth[1]%>"><%=reportEntity.getSubject()%></TD>
							<TD class="resultFont" width="<%=columnWidth[2]%>" style="text-align: center;">
																								<%="&nbsp;"+new SimpleDateFormat("dd/MM/yy").format(reportEntity.getOpenCaseDate())%></TD>
							<TD class="resultFont" width="<%=columnWidth[3]%>"><%=reportEntity.getStatusDesc(reportEntity.getCaseStatus())%></TD>
							<TD class="resultFont" width="<%=columnWidth[4]%>">
																		<%//=reportEntity.getCountry().getCountryName()==null? "Undefined":reportEntity.getCountry().getCountryName()</TD>%>
																								<%=reportEntity.getCfhdModule()==null? "Undefined":reportEntity.getCfhdModule()%></TD>
																								<%//=reportEntity.getCfhdSystem()==null? "Undefined":reportEntity.getCfhdSystem()</TD>%>
							<TD class="resultFont" width="<%=columnWidth[5]%>" style="text-align: center;"><%=reportEntity.getCaseType()%></TD>
						</TR>
					</TABLE>
			</TD>
	</TR>
<%
							countryPre			=	reportEntity.getCountry().getCountryName();
				}// end FOR write all data.
		}//end FOR loop of start-count 'Case type'

if (vectorSize == 0){
%>
	<TR>
			<TD><TABLE width="<%=tableWidth%>" cellspacing="0" cellpadding="0"><TR><TD>&nbsp;</TD></TR></TABLE></TD>
	</TR>
<%}%>

	<TR>
			<TD style="border-top: solid 2px #FF8C00">
					<TABLE cellspacing="0" align="right" border="0" bordercolor="green">
						<TR >
							<TD class="TotalByCaseTyephaveline" width="150">Total by Country</TD>
							<TD class="TotalByCaseTyephaveline" style="text-align: center;"><%=countCountry%></TD>
							<TD class="TotalByCaseTyephaveline">Cases</TD>
						</TR>
					</TABLE>
			</TD>
	</TR>
<%	 }// end if country is ALL or not%>
	<TR>
			<TD>
					<TABLE cellspacing="0" align="right" border="0" bordercolor="green">
						<TR >
							<TD class="TotalByCaseTyephavelineDoble" width="150">Total by System</TD>
							<TD class="TotalByCaseTyephavelineDoble" style="text-align: center;"><%=countSystem%></TD>
							<TD class="TotalByCaseTyephavelineDoble">Cases</TD>
						</TR>
					</TABLE>
			</TD>
	</TR>
	<TR style="height: 5px;"><TD style="border-bottom: 3px black solid;"><TABLE><TR><TD></TD></TR></TABLE></TD></TR>
<%}// end if system is ALL or not%>








	<TR>
			<TD>
					<TABLE cellspacing="0" align="right" border="0" bordercolor="green">
						<TR >
							<TD class="TotalByCaseTyephavelineDobleForGrandTotal" width="150">Grand Total</TD>
							<TD class="TotalByCaseTyephavelineDobleForGrandTotal" style="text-align: center;"><%=vectorSizeGrand%></TD>
							<TD class="TotalByCaseTyephavelineDobleForGrandTotal">Cases</TD>
						</TR>
					</TABLE>
			</TD>
	</TR>
</TABLE>
</DIV>
</BODY>
</HTML>